'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
  async index() {
    const { ctx, app } = this;
    // ctx.body = {
    //   code: 1,
    //   msg: '跨域接口测试'
    // };
    const token = app.jwt.sign({
      username: 'admin'
    }, app.config.jwt.config, {
      expiresIn: '7 days'
    })
    const queryresult = await ctx.service.user.findByUsername('admin')
    ctx.body = {
      token,
      queryresult
    }
  }
}

module.exports = HomeController;
